import { createRouter, createWebHashHistory } from 'vue-router';
// import routes from 'virtual:generated-pages';
import NProgress from 'nprogress';
import 'nprogress/nprogress.css';
import { routes as menuRoutes } from './menuRoute';

// 公共路由
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    hidden: true,
  },
];

const routes = [
  {
    path: '/',
    redirect: 'super-search',
  },
  {
    path: '/login-zhicheng',
    name: 'login-zhicheng',
    component: () => import('@/views/login-zhicheng/index.vue'),
  },
  {
    path: '/repwd-zhicheng',
    name: 'repwd-zhicheng',
    component: () => import('@/views/repwd-zhicheng/index.vue'),
  },
  {
    path: '/pwdManage-zhicheng',
    name: 'pwdManage-zhicheng',
    component: () => import('@/views/pwdManage-zhicheng/index.vue'),
  },
  {
    path: '/super-search-result', // 超级搜索结果页
    name: 'super-search-result',
    component: () => import('@/views/5g/super-search/super-search-result.vue'),
  },
  {
    path: '/',
    name: 'index',
    component: () => import('@/views/index.vue'),
    children: [
      // 5g用
      {
        path: '/super-search', // 超级搜索
        name: 'super-search',
        component: () => import('@/views/5g/super-search/index.vue'),
      },
      {
        path: '/holographic-archives', // 全息档案
        name: 'holographic-archives',
        component: () => import('@/views/5g/holographic-archives/index.vue'),
      },
      // 测试用
      {
        path: '/home',
        name: 'home',
        component: () => import('@/views/home/index.vue'),
      },
      {
        path: '/page1',
        name: 'page1',
        component: () => import('@/views/page1/index.vue'),
      },
      {
        path: '/page2',
        name: 'page2',
        component: () => import('@/views/page2/index.vue'),
      },
      {
        path: '/page3',
        name: 'page3',
        component: () => import('@/views/page3/index.vue'),
      },
    ],
  },
];
// routes.push({
//   path: '/',
//   redirect: '/login',
// });
//导入生成的路由数据
const router = createRouter({
  history: createWebHashHistory(),
  routes: [...routes, ...menuRoutes, ...constantRoutes],
});

router.beforeEach(async (_to, _from, next) => {
  NProgress.start();
  next();
});

router.afterEach((_to) => {
  NProgress.done();
});

export default router;
